<?php

class page_menus extends Model {

	public $page_id = false;
public $page_name = false;
public $page_data_id = false;
public $page_menu_title = false;
public $page_status = false;
public $menu_id = false;
public $page_data_menu_type = false;
public $page_parent_id = false;
public $page_pos = false;



    function page_menus()
    {
        // Call the Model constructor
        parent::Model();
		$this->_table_name = 'vw_page_menus';
		$this->_primary_key = 'page_data_id';
    }
	
	public function get_breadcrumb($iPageId = 0)
	{
		$this->clear();
		$this->page_id = $iPageId;
		$this->page_status = 'LI';
		
		$aRet = array();
		
		$bHasParent = true;
		
		$i = 0;
		while ($bHasParent === true)
		{
			$i++;
			
			if ($i >= 4)
			{
				$bHasParent = false;	
			}
			else 
			{
				$qPage = $this->get(array(), 1);
					
				if ($qPage->num_rows() === 1)
				{
					$aRet[] = $qPage->row(0);
					
					if ($qPage->row(0)->page_id === $qPage->row(0)->page_parent_id)
					{
						$bHasParent = false;
					}
					else 
					{
						$this->page_id = $qPage->row(0)->page_parent_id;
					}
				}
				else
				{
					$bHasParent = false;
				}
			}
		}
		
		return $aRet;
	}
}

?>